// import Analysis from "./component/analysis";
import DataOverview from "./NewComponents/DataOverview.vue"
// import FansPortrait from "./component/FansPortrait";
import LiveDetail from  "./NewComponents/LiveDetail"
// import TalentVideo from "./component/talentVideo";
import CargoAnalysis from "./NewComponents/CargoAnalysis"
// import Ecommerce from "./component/Ecommerce";
import VideoDetail from "./NewComponents/VideoDetail"
// import liveRecord from "./component/liveRecord";
import FansAnalysis from  "./NewComponents/FansAnalysis"
// import liveData from "./component/liveData";
// import StarMap from "./component/StarMap";
// import VueQr from "vue-qr";
import KChart from "./NewComponents/KChart.vue"
export default {
  components: {
    // Analysis,
    // FansPortrait,
    // VueQr,
    // TalentVideo,
    // Ecommerce,
    // liveRecord,
    // liveData,
    // StarMap,
    DataOverview,
    LiveDetail,
    CargoAnalysis,
    VideoDetail,
    FansAnalysis,
    KChart
  },
  data() {
    return {
      input_btn: "达人分析",
      authorId: "",
      open: false,
      showOpen: false,
      playing: true,
      star: 0,
      activeName: "0",
      infoData: [],
      dataOverView: {},
      liveElectricBusinessData: {},
      starMapHints: [],
      shareLink: "",
      show: true,
      fixedFlag: false,
      cancel: null,
      cancel01: null,
      finishLeft: false,
      showBtn: true, //展开==收起
      showPopup: false, //更多按钮
      scareValue: 3, //口碑评分
      showMouthEchart: false,
      showFansEchart: false,
      showFabulousEchart: false,
      changeBoard: true
      // ranks: {
      //   1: ["颜值达人排行榜周榜第1名", '音乐排行榜日榜第1名', '情感排行榜日榜第1名', '情感排行榜日榜第1名'],
      //   2: ["1颜排行榜周榜第1名", '1情感排行榜日榜第1名', '1情感排行榜日榜第1名']
      // }, //1:行业排行榜
    };
  },
  computed: {
    sliceStr() {
      if (this.infoData.introduce != null) {
          return this.infoData.introduce.substring(0, 30) + "...";
      }
      return '';
    }
  },
  watch: {
    input_btn: function(newVal, oldVal) {
      if (newVal == "达人分析") {
        this.input_btn = "达人分析";
      } else if ((newVal = "达人视频")) {
        this.input_btn == "达人视频";
      } else if (newVal == "粉丝画像") {
        this.input_btn == "粉丝画像";
      } else if (newVal == "电商数据分析") {
        this.input_btn == "电商数据分析";
      } else if (newVal == "直播记录") {
        this.input_btn == "直播记录";
      }
    }
  },
  created() {
    this.authorId = this.$route.params.id;
    if (this.$route.params.index) {
      this.activeName = this.$route.params.index;
    }
    // console.log('authorId', this.authorId)
    // console.log('activeName', this.activeName)
    this.getInfoData();
  },
  mounted() {},

  methods: {
    // 收藏
    addStar() {
      let that = this;
      that.$axios
        .post(
          "/api/collection/InsertCollection",
          {
            CollectId: that.authorId,
            Module: 1 //模块 1达人 2视频 3音乐 4话题 5商品
          },
          {
            cancelToken: new that.$axios.CancelToken(function executor(c) {
              if (that.cancel != null) {
                that.cancel();
              }
              that.cancel = c;
            })
          }
        )
        .then(res => {
          if (res.data.code == 0) {
            that.infoData.isCollect = 1;
          }
        })
        .catch(err => {
          console.log(err);
        });
    },
    // 取消收藏
    cancelStar() {
      let that = this;
      that.$axios
        .post(
          "/api/collection/CancelCollection",
          {
            CollectId: that.authorId,
            Module: 1 //模块 1达人 2视频 3音乐 4话题 5商品
          },
          {
            cancelToken: new that.$axios.CancelToken(function executor(c) {
              if (that.cancel01 != null) {
                that.cancel01();
              }
              that.cancel01 = c;
            })
          }
        )
        .then(res => {
          if (res.data.code == 0) {
            that.infoData.isCollect = 0;
          }
        })
        .catch(err => {
          console.log(err);
        });
    },
    // 获取左侧详情数据
    getInfoData() {
      let that = this;
      that.finishLeft = false;
      this.$axios
        .get("/api/author/GetAuthorDetailInfo", {
          params: {
            // authorId: "106073884943"
            'authorId': that.authorId,
            'api-version':'2.0'
          }
        })
        .then(res => {
          if (res.data.code == 0) {
            that.infoData = res.data.data;
            that.dataOverView = res.data.data.dataOverView;
            that.liveElectricBusinessData =
              res.data.data.liveElectricBusinessData;
            let rankArr = Object.values(res.data.data.ranks);
            let len = 0;
            rankArr.forEach(element => {
              len += element.length;
            });
            // console.log('len', len)
            if (len > 3) {
              that.showOpen = true;
            } else {
              that.showOpen = false;
            }
            that.shareLink = res.data.data.shareLink;
            // 星图指数
            that.starMapHints = res.data.data.starMapHints;
            that.finishLeft = true;

            // that.star = res.data.data.isCollect
          }
        })
        .catch(err => {
          console.log(err);
        });
    },

    toRankPage(index, item1) {
      // console.log('index', index)
      // console.log('item1', item1)
      let str1 = "";
      let str2 = "";
      if (index == 1) {
        str1 = item1.match(/(\S*)排行榜/)[1];
        str2 = item1.match(/排行榜(\S*)第/)[1];
      }
      // console.log('str1', str1)
      // console.log('str2', str2)
      this.$router.push({
        path: `/talent_main/fans_main/${index}/${str1}/${str2}`
      });
    }
  }
};
